const express = require('express');
const router = express.Router();
const chapter = require('../model/chapter')
const novel = require('../model/novel')
const detail = require('../model/detail')


router.post('/nover_hot',function (req, res) {
    const novelModel = new novel
    novelModel.banner(1,8).then(ret=>{
        console.log("=====",ret)
        return res.json({ret_code: 2, ret_msg: '成功',data:ret})
    })
})

router.post('/chapter', function(req, res) {
    const param = req.body
    console.log('参数',param)
    const chapterModel = new chapter
    chapterModel.chapeterlist(param.nid,1,300).then(ret=>{
        console.log("=====",ret)
        return res.json({ret_code: 2, ret_msg: '成功',data:ret})
    })

});

router.post('/novel_info',function (req,res) {
  const param = req.body
  console.log('参数',param)
  const novelModel = new novel
  novelModel.novel_info(param.nid,1,20).then(ret=>{
    console.log("=====",ret)
    return res.json({ret_code: 2, ret_msg: '成功',data:ret})
  })
});

router.post('/detail',function (req,res) {
    const param = req.body
    console.log('参数',param)
    const detailModel = new detail
    detailModel.detail(param.id).then(ret=>{
        console.log("detail==",ret)
        return res.json({ret_code: 2, ret_msg: '成功',data:ret})
    })
});


module.exports = router;
